﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dia2Lib;
using System.Diagnostics;

namespace Kokomo.Mirror.PeFormat.Symbols
{
	[DebuggerDisplay("{Name} (Rows={RowCount})")]
	public class Table : SymbolBase
	{
		internal static Table FromDiaTable(
			IDiaTable diaTable,
			SymbolSource source
			)
		{
			Table table;

			if (diaTable is IDiaEnumSymbols)
				table = new SymbolTable(diaTable, source);
			else if (diaTable is IDiaEnumInjectedSources)
				table = new InjectedSourceTable(diaTable, source);
			else
				table = new Table(diaTable, source);

			return table;
		}

		internal Table(IDiaTable table, SymbolSource source)
			: base(source)
		{
			if (table == null) throw new ArgumentNullException("table");
			this._table = new ComWrapper<IDiaTable>(table);
		}

		private ComWrapper<IDiaTable> _table;
		internal IDiaTable DiaTable { get { return this._table.Object; } }

		public string Name { get { return this.DiaTable.name; } }
		public int RowCount { get { return this.DiaTable.count; } }
	}
}
